#!/bin/bash


init_compile_env()
{
	if rpm -q envmaker &> /dev/null; then
		yum remove -y envmaker
	fi
	yum install envmaker -y -c ${REPO_CONF}
	if [ $? -ne 0 ];then
		echo "install envmaker error."
		exit 1
	fi

	repo_conf="/opt/envmaker/config/${ARCH}/openEuler_repo.conf"
	env_file_name="openEuler_compile_env_${ARCH}-1.0.0.tar.gz"

	cd /opt/envmaker/
	cp ${REPO_CONF} ${repo_conf}
	bash envmaker.sh -p openEuler_compile_env_${ARCH} -v 1.0.0
	if [ $? -ne 0 ];then
		echo "make compile env failed"
		exit 1
	fi

	cd "/opt/envmaker/result/$(date +%Y)"*
	if [ ! -s "${env_file_name}" ];then
		echo "make compile env failed."
		exit 1
	fi

	tar -xf openEuler_compile_env_${ARCH}-1.0.0.tar.gz -C /
	cp "/etc/resolv.conf" "${root_path}/etc/"
	cp -a "${LKP_SRC}/"* ${chroot_lkp}
}
